/**
 * 档案归还----归还申请
 */
import React from "react";
import PropTypes from "prop-types";
import { routerRedux } from "dva/router";
import { connect } from "dva";
import { Row, Col, Button, Tabs } from "antd";
import Tab from "./Tab";
import ReturnModal from "./Modal";
// import Filter from "./Filter";

const TabPane = Tabs.TabPane;

class Application extends React.Component {
  constructor(props) {
    super(props);
    this.state = {};
  }

  componentDidMount() {
    const { getList, menus, pagination } = this.props
    const params = {
      operatingState: menus,
      page: pagination.current
    }
    getList(params)
  }

  render() {
    const {
      list,
      pagination,
      modalVisibleReturn,
      currentItem,
      userList,
      menus,
      dispatch,
      loading
    } = this.props;

    // const { list, pagination, modalVisibleReturn, currentItem } = returns;
    // const { userList } = fileChange;
    const showModal = record => {
      dispatch({
        type: "returns/showReturnModal",
        payload: { record }
      });
      dispatch({
        type: "fileChange/useLists"
      });
    };
    const handleOk = value => {
      dispatch({
        type: "returns/updateApplication",
        payload: value
      });
      hideModal();
    };
    const hideModal = () => {
      dispatch({
        type: "returns/hideReturnModal"
      });
    };
    const handleSearch = value => {
      dispatch({
        type: "returns/query",
        payload: { ...value }
      });
    };
    const tabProps = {
      loading: loading.effects['returns/query'],
      dataSource: list,
      // rowKey: record => record.borrowId,
      pagination,
      onChange(page) {
        dispatch({
          type: "returns/query",
          payload: { page: page.current, pageSize: page.pageSize }
        });
      },
      showModal: showModal
    };
    const modalProps = {
      title: "档案归还",
      visible: modalVisibleReturn,
      onCancel: hideModal,
      onOk: handleOk,
      currentItem,
      userList
    };
    const filterProps = {
      handleSearch
    };
    return (
      <div>
        {/* <Filter {...filterProps} /> */}
        <Tab {...tabProps} />
        {modalVisibleReturn && <ReturnModal {...modalProps} />}
      </div>
    );
  };
}
Application.propTypes = {
  location: PropTypes.object,
  returns: PropTypes.object,
  dispatch: PropTypes.func,
  loading: PropTypes.object
};

export default connect(({ loading, returns, fileChange }) => ({
  loading,
  returns,
  fileChange
}))(Application);
